package com.tuliyou.controller;

import com.tuliyou.common.util.Result;
import com.tuliyou.dto.PageInfo;
import com.tuliyou.dto.UniversityDTO;
import com.tuliyou.service.UniversityService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/universities")
public class UniversityController {

    @Resource
    private UniversityService universityService;

    @GetMapping
    public Result<PageInfo<UniversityDTO>> universities(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer size,
            @RequestParam(required = false) String name, // 模糊查询
            @RequestParam(required = false) String province,
            @RequestParam(required = false) String city,
            @RequestParam(required = false) String level, // 模糊查询
            @RequestParam(required = false) String attribute
    ){
        return universityService.getUniversities(page,size,name,province,city,level,attribute);
    }

    @GetMapping("/{universityCode}")
    public Result<UniversityDTO> getUniversityDetail(@PathVariable("universityCode") String universityCode){
        return universityService.getUniversityDetail(universityCode);
    }
}
